#mogrify 20110826-F29_A1_1_400.png -thumbnail 70x70
#convert -resize 75X75 -quality 80 20110826-F29_A1_1_461.png 20110826-F29_A1_1_461_80.jpg

import os
import sys

if (len(sys.argv) != 4):
        print "Requires full_image_dir quality[1..100] size[Width_Height]"
        sys.exit(-1)

imgpath = sys.argv[1]
quality = sys.argv[2]
resize = sys.argv[3].replace("_", "X")
experiment = imgpath.split("/")[-1]

#outcmd = open(experiment + ".imcmd.out", "w")
for filename in os.listdir(imgpath):
        if (filename[-3:] == "png"):
                im_cmd = "convert -resize %s! -quality %s '%s/%s' '%s/%s'" %(resize, quality, imgpath, filename, imgpath, filename[0:-4] + "_icon.png")
                #print "Processing " + im_cmd
                os.system(im_cmd)
                #outcmd.write(im_cmd + "\n");
#outcmd.close()

